package demo2.demo2.service.impl;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.jws.WebService;

import demo2.demo2.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import demo2.demo2.entity.User;
import demo2.demo2.service.UserService;
/**
 * @ClassName:UserServiceImpl
 * @Description:测试服务接口实现类
 */
@WebService(serviceName="UserService",//对外发布的服务名
        targetNamespace="http://service.demo2.demo2",//指定你想要的名称空间，通常使用使用包名反转
        endpointInterface="demo2.demo2.service.UserService")//服务接口全路径, 指定做SEI（Service EndPoint Interface）服务端点接口
@Component
public class UserServiceImpl implements UserService{

    private Map<String, User> userMap = new HashMap<String, User>();
    public UserServiceImpl() {
        System.out.println("向实体类插入数据");
        User user = new User();
        user.setUserId("1");
        user.setUserName("test1");
        user.setEmail("jiade@163.xom");
        userMap.put(user.getUserId(), user);

        user = new User();
        user.setUserId("2");
        user.setUserName("test2");
        user.setEmail("jiade@163.xom");
        userMap.put(user.getUserId(), user);

        user = new User();
        user.setUserId("3");
        user.setUserName("test3");
        user.setEmail("jiade@163.xom");
        userMap.put(user.getUserId(), user);
    }

    @Autowired
    private LoginService loginService;

    @Override
    public String getUserName(String userId) {
        loginService.login();
        return "userId为：" + userId;
    }
    @Override
    public String getUser(String userId) {
        loginService.login();
        System.out.println("userMap是:"+userMap);
        return userMap.get(userId).toString();
    }

}